import express from 'express';
import user from './routes/user_knex.js';
const app = express();

// 后端解决跨域问题
app.use((req, res, next) => {
    // 允许所有来源
    res.header('Access-Control-Allow-Origin', '*')
    // 允许所有请求方式
    res.header('Access-Control-Allow-Methods', 'PUT,POST,GET,DELETE,OPTIONS')
    // 允许所有请求头
    res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization')
    // 放行
    next()
})
app.use(express.json());
app.use('/user', user);

app.listen(3000, () => {
    console.log('Server is running on port http://localhost:3000');
})